{// 加载头部公共文件 }
<include file="Public:header" />
<script>
$(function(){
	var appdialog=$("#appDialog");
	$(".appedit").on("click",function(){
		var $id=$(this).attr("id");
		var $tel=$(this).attr("data-tel");
		var $birthday=$(this).attr("data-birthday");
		var $address=$(this).attr("data-address");
		var $uid=$(this).attr("data-uid");
		appdialog.modal("show").find("table td:even").css("background","#f9f9f9").css("boder-color","#ddd").css("color","#000");
		$("#aid").val($id);
		$("#name").html($("#name_"+$id).html());
		$("#dname").html($("#dname_"+$id).html());
		$("#tel").html($tel);
		
		$("#birthday").html($birthday);
		$("#address").html($address);
		$("#sex").html($("#sex_"+$id).html());
		$("#truename").html($("#truename_"+$id).html());
		//$("#state").val($(this).attr("data-state"));
		$("#day").html($("#day_"+$id).html()+" "+$("#time_"+$id).html());
		$("#mobile").html($("#mobile_"+$id).html());
		$("#uid").html($(this).attr("data-id"));

	});	

	$("#close").on("click",function(){
		appdialog.modal("hide");	
	})
	$("#edit").on("click",function(){
		$.ajax({
			url:"{:U('admin/appoint/save/')}",type:"get",dataType:"json",cache:false,data:{
				aid:$("#aid").val(),state:$("#state").val()
			}
		}).done(function(data){	
			appdialog.modal("hide");
			if(data.info=="success"){
				location.reload();
			}
			showTip(data.info,"edit");
		})	
	})

	function showTip(result, mode) {
		if (result == "success") {
			if (mode == "edit") {
				$("#successAlert").html('编辑成功！');
			}
			$("#successAlert").slideDown();
			window.setTimeout(function(){$("#successAlert").slideUp();}, 3000);
		} else {
			if (mode == "edit") {
				$("#errorAlert").html('编辑失败！');
			}
			$("#errorAlert").slideDown();
			window.setTimeout(function(){$("#errorAlert").slideUp();}, 3000);
		}
	}

})
</script>
<div class="container">
	<div id="successAlert" class="alert alert-success fade in"></div>
	<div id="errorAlert" class="alert alert-danger fade in"></div>

	<table class="table table-striped">
		<tr>
			<th>预约日期</th><th>时间</th><th>预约者</th><th>性别</th><th>预约科室</th><th>预约医生</th><th>预约状态</th><th>联系方式</th><th>操作</th>
		</tr>
		<volist name="list" id="vo">
		<tr>
			<td id="day_{$vo.aid}">{$vo.day}</td>
			<td id="time_{$vo.aid}">{$vo.week} {$vo.time}</td>
			<td id="truename_{$vo.aid}">{$vo.truename}</td>	
			<td id="sex_{$vo.aid}">{$vo['sex']|getSex}</td>	
			<td id="name_{$vo.aid}">{$vo.name}</td>				
			<td id="dname_{$vo.aid}">{$vo.dname}</td>	
			<td id="state_{$vo.aid}">{$vo['state']|getState}</td>	
			<td id="mobile_{$vo.aid}">{$vo.mobile}</td>	
			<td>
			<if condition="$vo.state eq 1 ">
			<a href="#" id="{$vo.aid}" data-id="{$vo.id}" data-uid="{$vo.uid}" data-tel="{$vo.tel}" data-birthday="{$vo.birthday}" data-address="{$vo.address}" data-state="{$vo.state}" class="btn btn-primary btn-xs appedit">取消</a>
			</if></td>
		</tr>
		</volist>
	</table>
	
	<ul class="pagination">{$page}</ul>
</div> <!-- /container -->
<!-- channelResDialog start -->
<div id="appDialog" class="modal" tabindex="-1">
	<div class="modal-dialog" style="width: 550px;">
		<div class="modal-content">
			<div class="modal-header">
				<h4>编辑预约记录</h4>
			</div>
			<div class="modal-body">
				<input type="hidden" value="" id="aid"/>
				<table class="table table-hover">
					<tr><td style="width:90px">预约科室：</td><td id="name"></td><td style="width:90px">预约医生：</td><td id="dname"></td></tr>
					<tr>
						<td>预约日期：</td><td id="day"></td>
						<td>预约状态：</td><td>
						<select id="state">
						<option value="3">取消</option>
						</select></td>
					</tr>
					<tr><td>预约者：</td><td id="truename"></td><td>身份证：</td><td id="uid"></td></tr>
					<tr><td>性别：</td><td id="sex"></td><td>出生年月：</td><td id="birthday"></td></tr>
					<tr><td>联系手机：</td><td id="mobile"></td><td>联系电话：</td><td id="tel"></td></tr>
					<tr><td>联系地址：</td><td id="address" colspan="3"></td></tr>
				</table>
			</div>
			<div class="modal-footer">
				<button class="btn btn-default" id="close">
					取消
				</button>
				<button class="btn btn-primary" id="edit">
					确认
				</button>
			</div>
		</div>
	</div>
</div>

<!-- 主页面结束 -->
{// 加载尾部公共文件 }
<include file="Public:footer" />